﻿using System;

namespace EmbeddedSharp.Core.Function.String {
    public class TrimNode : FuncNode {

        public TrimNode()
            : base() {
            base.Value = "trim";
        }

        public override object Evaluate() {
            int length = Parameters.Count;
            if (length < 1) {
                throw new ArgumentException("usage: trim(expr)");
            }

            string expr = Parameters[0].Evaluate().ToString();

            return expr.Trim();
        }
    }
}
